package onlineCodingQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url(value(producer("/api/v3/onlineCodingQuizzes/students/1/assignments/1/quizzes/1")
                , consumer(regex("/api/v3/onlineCodingQuizzes/students/\\d+/assignments/\\d+/quizzes/\\d+"))))
    }
    response {
        status(200)
        body("""
            [{
                "id": 1,
                "description": "description",
                "evaluateScript": "evaluateScript",
                "templateRepository": "templateRepository",
                "makerId": 1,
                "onlineCodingName": "name",
                "language": "java",
                "createTime": 2018,
                "answerPath": "answerPath",
                "stackId": 1,
                "rawId": 1,
                "answerDescription": "answerDescription",
                "definitionRepo": "definitionRepo",
                "status": 2,
                "buildNumber": 2,
                "quizGroupId": 1,
                "remark": "remark",
                "tags": [],
                "available": true,
                "userAnswer": "userAnswer",
                "answerBranch": null
            }]
            """)
        bodyMatchers {
            jsonPath('$[*].id', byRegex(number()))
            jsonPath('$[*].description', byRegex("[\\s\\S]+"))
            jsonPath('$[*].evaluateScript', byRegex("[\\s\\S]+"))
            jsonPath('$[*].templateRepository', byRegex("[\\s\\S]+"))
            jsonPath('$[*].makerId', byRegex(number()))
            jsonPath('$[*].onlineCodingName', byRegex("[\\s\\S]+"))
            jsonPath('$[*].language', byRegex("[\\s\\S]+"))
            jsonPath('$[*].answerPath', byRegex("[\\s\\S]+"))
            jsonPath('$[*].stackId', byRegex(number()))
            jsonPath('$[*].rawId', byRegex(number()))
            jsonPath('$[*].answerDescription', byRegex("[\\s\\S]+"))
            jsonPath('$[*].definitionRepo', byRegex("[\\s\\S]+"))
            jsonPath('$[*].status', byRegex(number()))
            jsonPath('$[*].buildNumber', byRegex(number()))
            jsonPath('$[*].quizGroupId', byRegex(number()))
            jsonPath('$[*].remark', byRegex("[\\s\\S]+"))
            jsonPath('$[*].tags', byRegex("[\\s\\S]+"))
            jsonPath('$[*].available', byRegex(anyBoolean()))
            jsonPath('$[*].userAnswer', byRegex("[\\s\\S]+"))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
